package com.itheima.factory;

import com.itheima.service.UserService;
import com.itheima.service.impl.UserServiceImplB;
import org.springframework.beans.factory.FactoryBean;

/**
 * @Author itheima
 * @Date 2022/4/23 15:51
 * 自定义FactoryBean类
 */
public class UserServiceFactoryBean implements FactoryBean<UserService> {
    /**
     * spring内部会调用该方法，将该工厂方法返回的对象放入到spring容器
     *
     * @return
     * @throws Exception
     */
    @Override
    public UserService getObject() throws Exception {
        System.out.println("UserServiceFactoryBean.getObject");
        return new UserServiceImplB();
    }

    /**
     * 放入到spring容器中的对象类型
     *
     * @return
     */
    @Override
    public Class<?> getObjectType() {
        return UserService.class;
    }
}
